bidirectional counter using arduino